package com.haoshuang.zhouzhoubang.ui.vm

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.OrderBean5
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class MemberConfirmSignViewModel : BaseViewModel() {
    val getMasterOrderBaseData = StatefulMutableLiveData<OrderBean5>()
    fun getMasterOrderBase(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<OrderBean5>("api/master_order/get_master_order_base", *params,
                onStart = {
                    getMasterOrderBaseData.value = StateData.Loading
                },
                onError = { code, msg ->
                    getMasterOrderBaseData.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getMasterOrderBaseData.value = StateData.Success(it)
                })
        }
    }

    /**
     * 签到
     */
    val masterOrderSignData = StatefulMutableLiveData<Any>()
    fun masterOrderSign(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<Any>("api/master_order/sign", *params,
                onStart = {
                    masterOrderSignData.value = StateData.Loading
                },
                onError = { code, msg ->
                    masterOrderSignData.value = StateData.Error(code, msg)
                }, onSuccess = {
                    masterOrderSignData.value = StateData.Success(it)
                })
        }
    }

}